home *** CD-ROM | disk | FTP | other *** search
/ SIGGRAPH 2002 Course Notes / SIGGRAPH 2002 - Course Notes - Disc 1.iso / pc / notes / 16 / supplemental-material / Gritz / expense1.sl < prev    next >
Encoding:
Text File  |  2002-04-05  |  807 b   |  27 lines

  1. surface expensive (float Ka = 1, Kd = 0.5, Ks = 0.5, roughness = 0.1;
  2.            color specularcolor = 1;
  3.            string bakename = "bake")
  4. {
  5.     string objname = "";
  6.     attribute ("identifier:name", objname);
  7.     string passname = "";
  8.     option ("user:pass", passname);
  9.     float bakingpass = match ("bake", passname);
  10.     color foo;
  11.     if (bakingpass != 0) {
  12.     foo = color noise(s*10,t*10);
  13.     string bakefilename = concat (objname, ".", bakename, ".bake");
  14.     bake (bakefilename, s, t, foo);
  15.     } else {
  16.     string filename = concat (objname, ".", bakename, ".tx");
  17.     foo = color texture (filename, s, t);
  18.     }
  19.  
  20.     color Ct = Cs * foo;
  21.  
  22.     normal Nf = faceforward (normalize(N),I);
  23.     Ci = Ct * (Ka*ambient() + Kd*diffuse(Nf)) +
  24.      specularcolor * Ks*specular(Nf,-normalize(I),roughness);
  25.     Oi = Os;  Ci *= Oi;
  26. }
  27.